<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
    session_start();
	if(!isset($_SESSION['userid'])){
		header("location:login.php");
	}
    include( "config/ini.php");
	$queryAll="select * from phpguestbook order by id";
	$resauls=mysql_query($queryAll);
?>


<div align="center">
	<a href="logout.php">退出</a>
	<span>welcome <?php $user= $_SESSION['userid']; echo $user['name']; ?>!!</span>
</div>
<table width="800"  border="1">
	<tr>
		<th>id</th>
		<th>用户名</th>
		<th>QQ</th>
		<th>email</th>
		<th>操作</th>
	</tr>
    <?php
      	while($row=mysql_fetch_array($resauls)){
		     echo "<tr align='center'>";
	         echo "<td>".$row['id']."</td>";
			 echo "<td>".$row['username']."</td>";
			 echo "<td>".$row['QQ']."</td>";
			 echo "<td>".$row['email']."</td>";	
			 echo "<td><a href='newData.php?upId=".$row['id']."'>修改</a>&nbsp;&nbsp;<a href='?delId=".$row['id']."'>删除</a></td>";		
			 echo "</tr>";
	    }
    ?>
</table>
<br/>
<div align="center"><a href="newData.php">新增</a></div>

<?php
   if(isset($_GET["delId"])){//删除
       $delId=$_GET["delId"];
   	   $delSql=mysql_query("delete from phpguestbook where id={$delId}");
       if($delSql){
       	  header("location:sqlStudy.php");
       }else{
       	   echo "alert('删除失败！')";
       }
   }
?>
